<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables, GADTs, BangPatterns #-}</span><span>
</span><span id="line-2"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.CmmToAsm.Reg.Graph.SpillCost</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-3"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostRecord"><span class="hs-identifier">SpillCostRecord</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-4"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostRecord"><span class="hs-identifier">plusSpillCostRecord</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-5"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#pprSpillCostRecord"><span class="hs-identifier">pprSpillCostRecord</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier">SpillCostInfo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-8"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#zeroSpillCostInfo"><span class="hs-identifier">zeroSpillCostInfo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-9"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostInfo"><span class="hs-identifier">plusSpillCostInfo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#slurpSpillCostInfo"><span class="hs-identifier">slurpSpillCostInfo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#chooseSpill"><span class="hs-identifier">chooseSpill</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#lifeMapFromSpillCostInfo"><span class="hs-identifier">lifeMapFromSpillCostInfo</span></a></span><span>
</span><span id="line-15"></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html"><span class="hs-identifier">GHC.CmmToAsm.Reg.Liveness</span></a></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html"><span class="hs-identifier">GHC.CmmToAsm.Instr</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.Class.html"><span class="hs-identifier">GHC.Platform.Reg.Class</span></a></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html"><span class="hs-identifier">GHC.Platform.Reg</span></a></span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Base.html"><span class="hs-identifier">GHC.Data.Graph.Base</span></a></span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Collections.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Collections</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier">mapLookup</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Label</span></a></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html"><span class="hs-identifier">GHC.Types.Unique.FM</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Directed.html"><span class="hs-identifier">GHC.Data.Graph.Directed</span></a></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Graph.html#flattenSCCs"><span class="hs-identifier">flattenSCCs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.State.html"><span class="hs-identifier">GHC.Utils.Monad.State</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html"><span class="hs-identifier">GHC.CmmToAsm.CFG</span></a></span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier">nub</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#minimumBy"><span class="hs-identifier">minimumBy</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#join"><span class="hs-identifier">join</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="hs-comment">-- | Records the expected cost to spill some register.</span><span>
</span><span id="line-42"></span><span class="hs-keyword">type</span><span> </span><span id="SpillCostRecord"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostRecord"><span class="hs-identifier hs-var">SpillCostRecord</span></a></span></span><span>
</span><span id="line-43"></span><span> </span><span class="hs-glyph">=</span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span>    </span><span class="hs-comment">-- register name</span><span>
</span><span id="line-44"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>           </span><span class="hs-comment">-- number of writes to this reg</span><span>
</span><span id="line-45"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>           </span><span class="hs-comment">-- number of reads from this reg</span><span>
</span><span id="line-46"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>          </span><span class="hs-comment">-- number of instrs this reg was live on entry to</span><span>
</span><span id="line-47"></span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-comment">-- | Map of `SpillCostRecord`</span><span>
</span><span id="line-50"></span><span class="hs-keyword">type</span><span> </span><span id="SpillCostInfo"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-var">SpillCostInfo</span></a></span></span><span>
</span><span id="line-51"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostRecord"><span class="hs-identifier hs-type">SpillCostRecord</span></a></span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-keyword">type</span><span> </span><span id="SpillCostState"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostState"><span class="hs-identifier hs-var">SpillCostState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.State.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-comment">-- | An empty map of spill costs.</span><span>
</span><span id="line-56"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#zeroSpillCostInfo"><span class="hs-identifier hs-type">zeroSpillCostInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span>
</span><span id="line-57"></span><span id="zeroSpillCostInfo"><span class="annot"><span class="annottext">zeroSpillCostInfo :: SpillCostInfo
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#zeroSpillCostInfo"><span class="hs-identifier hs-var hs-var">zeroSpillCostInfo</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
forall key elt. UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#emptyUFM"><span class="hs-identifier hs-var">emptyUFM</span></a></span><span>
</span><span id="line-58"></span><span>
</span><span id="line-59"></span><span>
</span><span id="line-60"></span><span class="hs-comment">-- | Add two spill cost infos.</span><span>
</span><span id="line-61"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostInfo"><span class="hs-identifier hs-type">plusSpillCostInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span>
</span><span id="line-62"></span><span id="plusSpillCostInfo"><span class="annot"><span class="annottext">plusSpillCostInfo :: SpillCostInfo -&gt; SpillCostInfo -&gt; SpillCostInfo
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostInfo"><span class="hs-identifier hs-var hs-var">plusSpillCostInfo</span></a></span></span><span> </span><span id="local-6989586621681025012"><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681025012"><span class="hs-identifier hs-var">sc1</span></a></span></span><span> </span><span id="local-6989586621681025011"><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681025011"><span class="hs-identifier hs-var">sc2</span></a></span></span><span>
</span><span id="line-63"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord)
-&gt; SpillCostInfo -&gt; SpillCostInfo -&gt; SpillCostInfo
forall elt key.
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; UniqFM key elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#plusUFM_C"><span class="hs-identifier hs-var">plusUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostRecord"><span class="hs-identifier hs-var">plusSpillCostRecord</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681025012"><span class="hs-identifier hs-var">sc1</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681025011"><span class="hs-identifier hs-var">sc2</span></a></span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span class="hs-comment">-- | Add two spill cost records.</span><span>
</span><span id="line-67"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostRecord"><span class="hs-identifier hs-type">plusSpillCostRecord</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostRecord"><span class="hs-identifier hs-type">SpillCostRecord</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostRecord"><span class="hs-identifier hs-type">SpillCostRecord</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostRecord"><span class="hs-identifier hs-type">SpillCostRecord</span></a></span><span>
</span><span id="line-68"></span><span id="plusSpillCostRecord"><span class="annot"><span class="annottext">plusSpillCostRecord :: SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostRecord"><span class="hs-identifier hs-var hs-var">plusSpillCostRecord</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681025009"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681025009"><span class="hs-identifier hs-var">r1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681025008"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025008"><span class="hs-identifier hs-var">a1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681025007"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025007"><span class="hs-identifier hs-var">b1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681025006"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025006"><span class="hs-identifier hs-var">c1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681025005"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681025005"><span class="hs-identifier hs-var">r2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681025004"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025004"><span class="hs-identifier hs-var">a2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681025003"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025003"><span class="hs-identifier hs-var">b2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681025002"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025002"><span class="hs-identifier hs-var">c2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681025009"><span class="hs-identifier hs-var">r1</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg -&gt; VirtualReg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681025005"><span class="hs-identifier hs-var">r2</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681025009"><span class="hs-identifier hs-var">r1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025008"><span class="hs-identifier hs-var">a1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025004"><span class="hs-identifier hs-var">a2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025007"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025003"><span class="hs-identifier hs-var">b2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025006"><span class="hs-identifier hs-var">c1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681025002"><span class="hs-identifier hs-var">c2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-70"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; SpillCostRecord
forall a. HasCallStack =&gt; [Char] -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;RegSpillCost.plusRegInt: regs don't match&quot;</span></span><span>
</span><span id="line-71"></span><span>
</span><span id="line-72"></span><span>
</span><span id="line-73"></span><span class="hs-comment">-- | Slurp out information used for determining spill costs.</span><span>
</span><span id="line-74"></span><span class="hs-comment">--</span><span>
</span><span id="line-75"></span><span class="hs-comment">--   For each vreg, the number of times it was written to, read from,</span><span>
</span><span id="line-76"></span><span class="hs-comment">--   and the number of instructions it was live on entry to (lifetime)</span><span>
</span><span id="line-77"></span><span class="hs-comment">--</span><span>
</span><span id="line-78"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#slurpSpillCostInfo"><span class="hs-identifier hs-type">slurpSpillCostInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621681025181"><span class="annot"><a href="#local-6989586621681025181"><span class="hs-identifier hs-type">instr</span></a></span></span><span> </span><span id="local-6989586621681025177"><span class="annot"><a href="#local-6989586621681025177"><span class="hs-identifier hs-type">statics</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681025181"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681025181"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-79"></span><span>                   </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-80"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.CFG.html#CFG"><span class="hs-identifier hs-type">CFG</span></a></span><span>
</span><span id="line-81"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveCmmDecl"><span class="hs-identifier hs-type">LiveCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681025177"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681025181"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-82"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span id="slurpSpillCostInfo"><span class="annot"><span class="annottext">slurpSpillCostInfo :: forall instr statics.
(Outputable instr, Instruction instr) =&gt;
Platform -&gt; Maybe CFG -&gt; LiveCmmDecl statics instr -&gt; SpillCostInfo
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#slurpSpillCostInfo"><span class="hs-identifier hs-var hs-var">slurpSpillCostInfo</span></a></span></span><span> </span><span id="local-6989586621681024951"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024951"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681024950"><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681024950"><span class="hs-identifier hs-var">cfg</span></a></span></span><span> </span><span id="local-6989586621681024949"><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024949"><span class="hs-identifier hs-var">cmm</span></a></span></span><span>
</span><span id="line-85"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State SpillCostInfo () -&gt; SpillCostInfo -&gt; SpillCostInfo
forall s a. State s a -&gt; s -&gt; s
</span><a href="GHC.Utils.Monad.State.html#execState"><span class="hs-identifier hs-var">execState</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveCmmDecl statics instr -&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024947"><span class="hs-identifier hs-var">countCmm</span></a></span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024949"><span class="hs-identifier hs-var">cmm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#zeroSpillCostInfo"><span class="hs-identifier hs-var">zeroSpillCostInfo</span></a></span><span>
</span><span id="line-86"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-87"></span><span>        </span><span id="local-6989586621681024947"><span class="annot"><span class="annottext">countCmm :: LiveCmmDecl statics instr -&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024947"><span class="hs-identifier hs-var hs-var">countCmm</span></a></span></span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmData"><span class="hs-identifier hs-type">CmmData</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; State SpillCostInfo ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span>        </span><span class="annot"><a href="#local-6989586621681024947"><span class="hs-identifier hs-var">countCmm</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-type">CmmProc</span></a></span><span> </span><span id="local-6989586621681024944"><span class="annot"><span class="annottext">LiveInfo
</span><a href="#local-6989586621681024944"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681024943"><span class="annot"><span class="annottext">[SCC (GenBasicBlock (LiveInstr instr))]
</span><a href="#local-6989586621681024943"><span class="hs-identifier hs-var">sccs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GenBasicBlock (LiveInstr instr) -&gt; State SpillCostInfo ())
-&gt; [GenBasicBlock (LiveInstr instr)] -&gt; State SpillCostInfo ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInfo
-&gt; Maybe (LabelMap Double)
-&gt; GenBasicBlock (LiveInstr instr)
-&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024941"><span class="hs-identifier hs-var">countBlock</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInfo
</span><a href="#local-6989586621681024944"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap Double)
</span><a href="#local-6989586621681024940"><span class="hs-identifier hs-var">freqMap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span>                </span><span class="annot"><span class="annottext">([GenBasicBlock (LiveInstr instr)] -&gt; State SpillCostInfo ())
-&gt; [GenBasicBlock (LiveInstr instr)] -&gt; State SpillCostInfo ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SCC (GenBasicBlock (LiveInstr instr))]
-&gt; [GenBasicBlock (LiveInstr instr)]
forall a. [SCC a] -&gt; [a]
</span><a href="../../containers/src/Data.Graph.html#flattenSCCs"><span class="hs-identifier hs-var">flattenSCCs</span></a></span><span> </span><span class="annot"><span class="annottext">[SCC (GenBasicBlock (LiveInstr instr))]
</span><a href="#local-6989586621681024943"><span class="hs-identifier hs-var">sccs</span></a></span><span>
</span><span id="line-91"></span><span>            </span><span class="hs-keyword">where</span><span>
</span><span id="line-92"></span><span>                </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInfo"><span class="hs-identifier hs-type">LiveInfo</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681024938"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681024938"><span class="hs-identifier hs-var">entries</span></a></span></span><span> </span><span class="annot"><span class="annottext">BlockMap RegSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LiveInfo
</span><a href="#local-6989586621681024944"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-93"></span><span>                </span><span id="local-6989586621681024940"><span class="annot"><span class="annottext">freqMap :: Maybe (LabelMap Double)
</span><a href="#local-6989586621681024940"><span class="hs-identifier hs-var hs-var">freqMap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LabelMap Double, LabelMap (LabelMap Double)) -&gt; LabelMap Double
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">((LabelMap Double, LabelMap (LabelMap Double)) -&gt; LabelMap Double)
-&gt; (CFG -&gt; (LabelMap Double, LabelMap (LabelMap Double)))
-&gt; CFG
-&gt; LabelMap Double
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt;
BlockId -&gt; CFG -&gt; (LabelMap Double, LabelMap (LabelMap Double))
BlockId -&gt; CFG -&gt; (LabelMap Double, LabelMap (LabelMap Double))
</span><a href="GHC.CmmToAsm.CFG.html#mkGlobalWeights"><span class="hs-identifier hs-var">mkGlobalWeights</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[BlockId] -&gt; BlockId
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681024938"><span class="hs-identifier hs-var">entries</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(CFG -&gt; LabelMap Double) -&gt; Maybe CFG -&gt; Maybe (LabelMap Double)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CFG
</span><a href="#local-6989586621681024950"><span class="hs-identifier hs-var">cfg</span></a></span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span>        </span><span class="hs-comment">-- Lookup the regs that are live on entry to this block in</span><span>
</span><span id="line-96"></span><span>        </span><span class="hs-comment">--      the info table from the CmmProc.</span><span>
</span><span id="line-97"></span><span>        </span><span id="local-6989586621681024941"><span class="annot"><span class="annottext">countBlock :: LiveInfo
-&gt; Maybe (LabelMap Double)
-&gt; GenBasicBlock (LiveInstr instr)
-&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024941"><span class="hs-identifier hs-var hs-var">countBlock</span></a></span></span><span> </span><span id="local-6989586621681024933"><span class="annot"><span class="annottext">LiveInfo
</span><a href="#local-6989586621681024933"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681024932"><span class="annot"><span class="annottext">Maybe (LabelMap Double)
</span><a href="#local-6989586621681024932"><span class="hs-identifier hs-var">freqMap</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681024930"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681024930"><span class="hs-identifier hs-var">blockId</span></a></span></span><span> </span><span id="local-6989586621681024929"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681024929"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInfo"><span class="hs-identifier hs-type">LiveInfo</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681024928"><span class="annot"><span class="annottext">BlockMap RegSet
</span><a href="#local-6989586621681024928"><span class="hs-identifier hs-var">blockLive</span></a></span></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInfo
</span><a href="#local-6989586621681024933"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-99"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681024927"><span class="annot"><span class="annottext">RegSet
</span><a href="#local-6989586621681024927"><span class="hs-identifier hs-var">rsLiveEntry</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; BlockMap RegSet -&gt; Maybe RegSet
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681024930"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap RegSet
</span><a href="#local-6989586621681024928"><span class="hs-identifier hs-var">blockLive</span></a></span><span>
</span><span id="line-100"></span><span>                </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681024926"><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024926"><span class="hs-identifier hs-var">rsLiveEntry_virt</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RegSet -&gt; UniqSet VirtualReg
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#takeVirtuals"><span class="hs-identifier hs-var">takeVirtuals</span></a></span><span> </span><span class="annot"><span class="annottext">RegSet
</span><a href="#local-6989586621681024927"><span class="hs-identifier hs-var">rsLiveEntry</span></a></span><span>
</span><span id="line-101"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; UniqSet VirtualReg
-&gt; [LiveInstr instr]
-&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024924"><span class="hs-identifier hs-var">countLIs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Double -&gt; Int
forall a b. (RealFrac a, Integral b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#ceiling"><span class="hs-identifier hs-var">ceiling</span></a></span><span> </span><span class="annot"><span class="annottext">(Double -&gt; Int) -&gt; Double -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap Double) -&gt; BlockId -&gt; Double
</span><a href="#local-6989586621681024922"><span class="hs-identifier hs-var">blockFreq</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap Double)
</span><a href="#local-6989586621681024932"><span class="hs-identifier hs-var">freqMap</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681024930"><span class="hs-identifier hs-var">blockId</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024926"><span class="hs-identifier hs-var">rsLiveEntry_virt</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681024929"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-102"></span><span>
</span><span id="line-103"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-104"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; State SpillCostInfo ()
forall a. HasCallStack =&gt; [Char] -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;RegAlloc.SpillCost.slurpSpillCostInfo: bad block&quot;</span></span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span>        </span><span class="annot"><a href="#local-6989586621681024924"><span class="hs-identifier hs-type">countLIs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#UniqSet"><span class="hs-identifier hs-type">UniqSet</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681025181"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostState"><span class="hs-identifier hs-type">SpillCostState</span></a></span><span>
</span><span id="line-108"></span><span>        </span><span id="local-6989586621681024924"><span class="annot"><span class="annottext">countLIs :: Int
-&gt; UniqSet VirtualReg
-&gt; [LiveInstr instr]
-&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024924"><span class="hs-identifier hs-var hs-var">countLIs</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>      </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-109"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; State SpillCostInfo ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span>        </span><span class="hs-comment">-- Skip over comment and delta pseudo instrs.</span><span>
</span><span id="line-112"></span><span>        </span><span class="annot"><a href="#local-6989586621681024924"><span class="hs-identifier hs-var">countLIs</span></a></span><span> </span><span id="local-6989586621681024921"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024921"><span class="hs-identifier hs-var">scale</span></a></span></span><span> </span><span id="local-6989586621681024920"><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024920"><span class="hs-identifier hs-var">rsLive</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span id="local-6989586621681024918"><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681024918"><span class="hs-identifier hs-var">instr</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681024917"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681024917"><span class="hs-identifier hs-var">lis</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-113"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">InstrSR instr -&gt; Bool
forall instr. Instruction instr =&gt; instr -&gt; Bool
</span><a href="GHC.CmmToAsm.Instr.html#isMetaInstr"><span class="hs-identifier hs-var">isMetaInstr</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681024918"><span class="hs-identifier hs-var">instr</span></a></span><span>
</span><span id="line-114"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; UniqSet VirtualReg
-&gt; [LiveInstr instr]
-&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024924"><span class="hs-identifier hs-var">countLIs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024921"><span class="hs-identifier hs-var">scale</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024920"><span class="hs-identifier hs-var">rsLive</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681024917"><span class="hs-identifier hs-var">lis</span></a></span><span>
</span><span id="line-115"></span><span>
</span><span id="line-116"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-117"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; SDoc -&gt; State SpillCostInfo ()
forall a. HasCallStack =&gt; [Char] -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;RegSpillCost.slurpSpillCostInfo&quot;</span></span><span>
</span><span id="line-118"></span><span>                </span><span class="annot"><span class="annottext">(SDoc -&gt; State SpillCostInfo ()) -&gt; SDoc -&gt; State SpillCostInfo ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;no liveness information on instruction &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681024918"><span class="hs-identifier hs-var">instr</span></a></span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span>        </span><span class="annot"><a href="#local-6989586621681024924"><span class="hs-identifier hs-var">countLIs</span></a></span><span> </span><span id="local-6989586621681024911"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024911"><span class="hs-identifier hs-var">scale</span></a></span></span><span> </span><span id="local-6989586621681024910"><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024910"><span class="hs-identifier hs-var">rsLiveEntry</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span id="local-6989586621681024909"><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681024909"><span class="hs-identifier hs-var">instr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681024908"><span class="annot"><span class="annottext">Liveness
</span><a href="#local-6989586621681024908"><span class="hs-identifier hs-var">live</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681024907"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681024907"><span class="hs-identifier hs-var">lis</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-121"></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-122"></span><span>                </span><span class="hs-comment">-- Increment the lifetime counts for regs live on entry to this instr.</span><span>
</span><span id="line-123"></span><span>                </span><span class="annot"><span class="annottext">(VirtualReg -&gt; State SpillCostInfo ())
-&gt; [VirtualReg] -&gt; State SpillCostInfo ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg -&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024906"><span class="hs-identifier hs-var">incLifetime</span></a></span><span> </span><span class="annot"><span class="annottext">([VirtualReg] -&gt; State SpillCostInfo ())
-&gt; [VirtualReg] -&gt; State SpillCostInfo ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg -&gt; [VirtualReg]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024910"><span class="hs-identifier hs-var">rsLiveEntry</span></a></span><span>
</span><span id="line-124"></span><span>                    </span><span class="hs-comment">-- This is non-deterministic but we do not</span><span>
</span><span id="line-125"></span><span>                    </span><span class="hs-comment">-- currently support deterministic code-generation.</span><span>
</span><span id="line-126"></span><span>                    </span><span class="hs-comment">-- See Note [Unique Determinism and code generation]</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span>                </span><span class="hs-comment">-- Increment counts for what regs were read/written from.</span><span>
</span><span id="line-129"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#RU"><span class="hs-identifier hs-type">RU</span></a></span><span> </span><span id="local-6989586621681024903"><span class="annot"><span class="annottext">[Reg]
</span><a href="#local-6989586621681024903"><span class="hs-identifier hs-var">read</span></a></span></span><span> </span><span id="local-6989586621681024902"><span class="annot"><span class="annottext">[Reg]
</span><a href="#local-6989586621681024902"><span class="hs-identifier hs-var">written</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; InstrSR instr -&gt; RegUsage
forall instr. Instruction instr =&gt; Platform -&gt; instr -&gt; RegUsage
</span><a href="GHC.CmmToAsm.Instr.html#regUsageOfInstr"><span class="hs-identifier hs-var">regUsageOfInstr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024951"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681024909"><span class="hs-identifier hs-var">instr</span></a></span><span>
</span><span id="line-130"></span><span>                </span><span class="annot"><span class="annottext">(VirtualReg -&gt; State SpillCostInfo ())
-&gt; [VirtualReg] -&gt; State SpillCostInfo ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; VirtualReg -&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024900"><span class="hs-identifier hs-var">incUses</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024911"><span class="hs-identifier hs-var">scale</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([VirtualReg] -&gt; State SpillCostInfo ())
-&gt; [VirtualReg] -&gt; State SpillCostInfo ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe VirtualReg] -&gt; [VirtualReg]
forall a. [Maybe a] -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">([Maybe VirtualReg] -&gt; [VirtualReg])
-&gt; [Maybe VirtualReg] -&gt; [VirtualReg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Reg -&gt; Maybe VirtualReg) -&gt; [Reg] -&gt; [Maybe VirtualReg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Reg -&gt; Maybe VirtualReg
</span><a href="GHC.Platform.Reg.html#takeVirtualReg"><span class="hs-identifier hs-var">takeVirtualReg</span></a></span><span> </span><span class="annot"><span class="annottext">([Reg] -&gt; [Maybe VirtualReg]) -&gt; [Reg] -&gt; [Maybe VirtualReg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Reg] -&gt; [Reg]
forall a. Eq a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier hs-var">nub</span></a></span><span> </span><span class="annot"><span class="annottext">[Reg]
</span><a href="#local-6989586621681024903"><span class="hs-identifier hs-var">read</span></a></span><span>
</span><span id="line-131"></span><span>                </span><span class="annot"><span class="annottext">(VirtualReg -&gt; State SpillCostInfo ())
-&gt; [VirtualReg] -&gt; State SpillCostInfo ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; VirtualReg -&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024897"><span class="hs-identifier hs-var">incDefs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024911"><span class="hs-identifier hs-var">scale</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([VirtualReg] -&gt; State SpillCostInfo ())
-&gt; [VirtualReg] -&gt; State SpillCostInfo ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe VirtualReg] -&gt; [VirtualReg]
forall a. [Maybe a] -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">([Maybe VirtualReg] -&gt; [VirtualReg])
-&gt; [Maybe VirtualReg] -&gt; [VirtualReg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Reg -&gt; Maybe VirtualReg) -&gt; [Reg] -&gt; [Maybe VirtualReg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Reg -&gt; Maybe VirtualReg
</span><a href="GHC.Platform.Reg.html#takeVirtualReg"><span class="hs-identifier hs-var">takeVirtualReg</span></a></span><span> </span><span class="annot"><span class="annottext">([Reg] -&gt; [Maybe VirtualReg]) -&gt; [Reg] -&gt; [Maybe VirtualReg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Reg] -&gt; [Reg]
forall a. Eq a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier hs-var">nub</span></a></span><span> </span><span class="annot"><span class="annottext">[Reg]
</span><a href="#local-6989586621681024902"><span class="hs-identifier hs-var">written</span></a></span><span>
</span><span id="line-132"></span><span>
</span><span id="line-133"></span><span>                </span><span class="hs-comment">-- Compute liveness for entry to next instruction.</span><span>
</span><span id="line-134"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681024896"><span class="annot"><span class="annottext">liveDieRead_virt :: UniqSet VirtualReg
</span><a href="#local-6989586621681024896"><span class="hs-identifier hs-var hs-var">liveDieRead_virt</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RegSet -&gt; UniqSet VirtualReg
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#takeVirtuals"><span class="hs-identifier hs-var">takeVirtuals</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Liveness -&gt; RegSet
</span><a href="GHC.CmmToAsm.Reg.Liveness.html#liveDieRead"><span class="hs-identifier hs-var hs-var">liveDieRead</span></a></span><span>  </span><span class="annot"><span class="annottext">Liveness
</span><a href="#local-6989586621681024908"><span class="hs-identifier hs-var">live</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-135"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681024894"><span class="annot"><span class="annottext">liveDieWrite_virt :: UniqSet VirtualReg
</span><a href="#local-6989586621681024894"><span class="hs-identifier hs-var hs-var">liveDieWrite_virt</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RegSet -&gt; UniqSet VirtualReg
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#takeVirtuals"><span class="hs-identifier hs-var">takeVirtuals</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Liveness -&gt; RegSet
</span><a href="GHC.CmmToAsm.Reg.Liveness.html#liveDieWrite"><span class="hs-identifier hs-var hs-var">liveDieWrite</span></a></span><span> </span><span class="annot"><span class="annottext">Liveness
</span><a href="#local-6989586621681024908"><span class="hs-identifier hs-var">live</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-136"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681024892"><span class="annot"><span class="annottext">liveBorn_virt :: UniqSet VirtualReg
</span><a href="#local-6989586621681024892"><span class="hs-identifier hs-var hs-var">liveBorn_virt</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RegSet -&gt; UniqSet VirtualReg
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#takeVirtuals"><span class="hs-identifier hs-var">takeVirtuals</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Liveness -&gt; RegSet
</span><a href="GHC.CmmToAsm.Reg.Liveness.html#liveBorn"><span class="hs-identifier hs-var hs-var">liveBorn</span></a></span><span>     </span><span class="annot"><span class="annottext">Liveness
</span><a href="#local-6989586621681024908"><span class="hs-identifier hs-var">live</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-137"></span><span>
</span><span id="line-138"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681024890"><span class="annot"><span class="annottext">rsLiveAcross :: UniqSet VirtualReg
</span><a href="#local-6989586621681024890"><span class="hs-identifier hs-var hs-var">rsLiveAcross</span></a></span></span><span>
</span><span id="line-139"></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024910"><span class="hs-identifier hs-var">rsLiveEntry</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg -&gt; UniqSet VirtualReg -&gt; UniqSet VirtualReg
forall a. UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#minusUniqSet"><span class="hs-operator hs-var">`minusUniqSet`</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024896"><span class="hs-identifier hs-var">liveDieRead_virt</span></a></span><span>
</span><span id="line-140"></span><span>
</span><span id="line-141"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681024888"><span class="annot"><span class="annottext">rsLiveNext :: UniqSet VirtualReg
</span><a href="#local-6989586621681024888"><span class="hs-identifier hs-var hs-var">rsLiveNext</span></a></span></span><span>
</span><span id="line-142"></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024890"><span class="hs-identifier hs-var">rsLiveAcross</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg -&gt; UniqSet VirtualReg -&gt; UniqSet VirtualReg
forall a. UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#unionUniqSets"><span class="hs-operator hs-var">`unionUniqSets`</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024892"><span class="hs-identifier hs-var">liveBorn_virt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-143"></span><span>                                        </span><span class="annot"><span class="annottext">UniqSet VirtualReg -&gt; UniqSet VirtualReg -&gt; UniqSet VirtualReg
forall a. UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#minusUniqSet"><span class="hs-operator hs-var">`minusUniqSet`</span></a></span><span>  </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024894"><span class="hs-identifier hs-var">liveDieWrite_virt</span></a></span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span>                </span><span class="annot"><span class="annottext">Int
-&gt; UniqSet VirtualReg
-&gt; [LiveInstr instr]
-&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024924"><span class="hs-identifier hs-var">countLIs</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024911"><span class="hs-identifier hs-var">scale</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg
</span><a href="#local-6989586621681024888"><span class="hs-identifier hs-var">rsLiveNext</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681024907"><span class="hs-identifier hs-var">lis</span></a></span><span>
</span><span id="line-146"></span><span>
</span><span id="line-147"></span><span>        </span><span id="local-6989586621681024897"><span class="annot"><span class="annottext">incDefs :: Int -&gt; VirtualReg -&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024897"><span class="hs-identifier hs-var hs-var">incDefs</span></a></span></span><span>     </span><span id="local-6989586621681024885"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024885"><span class="hs-identifier hs-var">count</span></a></span></span><span> </span><span id="local-6989586621681024884"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024884"><span class="hs-identifier hs-var">reg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ())
-&gt; (SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681024882"><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024882"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord)
-&gt; SpillCostInfo -&gt; VirtualReg -&gt; SpillCostRecord -&gt; SpillCostInfo
forall key elt.
Uniquable key =&gt;
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM_C"><span class="hs-identifier hs-var">addToUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostRecord"><span class="hs-identifier hs-var">plusSpillCostRecord</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024882"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024884"><span class="hs-identifier hs-var">reg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024884"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024885"><span class="hs-identifier hs-var">count</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>        </span><span id="local-6989586621681024900"><span class="annot"><span class="annottext">incUses :: Int -&gt; VirtualReg -&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024900"><span class="hs-identifier hs-var hs-var">incUses</span></a></span></span><span>     </span><span id="local-6989586621681024879"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024879"><span class="hs-identifier hs-var">count</span></a></span></span><span> </span><span id="local-6989586621681024878"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024878"><span class="hs-identifier hs-var">reg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ())
-&gt; (SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681024877"><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024877"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord)
-&gt; SpillCostInfo -&gt; VirtualReg -&gt; SpillCostRecord -&gt; SpillCostInfo
forall key elt.
Uniquable key =&gt;
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM_C"><span class="hs-identifier hs-var">addToUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostRecord"><span class="hs-identifier hs-var">plusSpillCostRecord</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024877"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024878"><span class="hs-identifier hs-var">reg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024878"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024879"><span class="hs-identifier hs-var">count</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>        </span><span id="local-6989586621681024906"><span class="annot"><span class="annottext">incLifetime :: VirtualReg -&gt; State SpillCostInfo ()
</span><a href="#local-6989586621681024906"><span class="hs-identifier hs-var hs-var">incLifetime</span></a></span></span><span>       </span><span id="local-6989586621681024875"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024875"><span class="hs-identifier hs-var">reg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ())
-&gt; (SpillCostInfo -&gt; SpillCostInfo) -&gt; State SpillCostInfo ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681024874"><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024874"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord)
-&gt; SpillCostInfo -&gt; VirtualReg -&gt; SpillCostRecord -&gt; SpillCostInfo
forall key elt.
Uniquable key =&gt;
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM_C"><span class="hs-identifier hs-var">addToUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostRecord -&gt; SpillCostRecord -&gt; SpillCostRecord
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#plusSpillCostRecord"><span class="hs-identifier hs-var">plusSpillCostRecord</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024874"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024875"><span class="hs-identifier hs-var">reg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024875"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-150"></span><span>
</span><span id="line-151"></span><span>        </span><span class="annot"><a href="#local-6989586621681024922"><span class="hs-identifier hs-type">blockFreq</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#LabelMap"><span class="hs-identifier hs-type">LabelMap</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#Label"><span class="hs-identifier hs-type">Label</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span>
</span><span id="line-152"></span><span>        </span><span id="local-6989586621681024922"><span class="annot"><span class="annottext">blockFreq :: Maybe (LabelMap Double) -&gt; BlockId -&gt; Double
</span><a href="#local-6989586621681024922"><span class="hs-identifier hs-var hs-var">blockFreq</span></a></span></span><span> </span><span id="local-6989586621681024872"><span class="annot"><span class="annottext">Maybe (LabelMap Double)
</span><a href="#local-6989586621681024872"><span class="hs-identifier hs-var">freqs</span></a></span></span><span> </span><span id="local-6989586621681024871"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681024871"><span class="hs-identifier hs-var">bid</span></a></span></span><span>
</span><span id="line-153"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681024870"><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681024870"><span class="hs-identifier hs-var">freq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (Maybe Double) -&gt; Maybe Double
forall (m :: * -&gt; *) a. Monad m =&gt; m (m a) -&gt; m a
</span><a href="../../base/src/GHC.Base.html#join"><span class="hs-identifier hs-var">join</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">KeyOf LabelMap -&gt; LabelMap Double -&gt; Maybe Double
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">KeyOf LabelMap
BlockId
</span><a href="#local-6989586621681024871"><span class="hs-identifier hs-var">bid</span></a></span><span> </span><span class="annot"><span class="annottext">(LabelMap Double -&gt; Maybe Double)
-&gt; Maybe (LabelMap Double) -&gt; Maybe (Maybe Double)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LabelMap Double)
</span><a href="#local-6989586621681024872"><span class="hs-identifier hs-var">freqs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">max</span></span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1.0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">10000</span></span><span> </span><span class="annot"><span class="annottext">Double -&gt; Double -&gt; Double
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Double
</span><a href="#local-6989586621681024870"><span class="hs-identifier hs-var">freq</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-155"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-156"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Double
</span><span class="hs-number">1.0</span></span><span> </span><span class="hs-comment">-- Only if no cfg given</span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="hs-comment">-- | Take all the virtual registers from this set.</span><span>
</span><span id="line-159"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#takeVirtuals"><span class="hs-identifier hs-type">takeVirtuals</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#UniqSet"><span class="hs-identifier hs-type">UniqSet</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#UniqSet"><span class="hs-identifier hs-type">UniqSet</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span>
</span><span id="line-160"></span><span id="takeVirtuals"><span class="annot"><span class="annottext">takeVirtuals :: RegSet -&gt; UniqSet VirtualReg
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#takeVirtuals"><span class="hs-identifier hs-var hs-var">takeVirtuals</span></a></span></span><span> </span><span id="local-6989586621681024867"><span class="annot"><span class="annottext">RegSet
</span><a href="#local-6989586621681024867"><span class="hs-identifier hs-var">set</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[VirtualReg] -&gt; UniqSet VirtualReg
forall a. Uniquable a =&gt; [a] -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#mkUniqSet"><span class="hs-identifier hs-var">mkUniqSet</span></a></span><span>
</span><span id="line-161"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024865"><span class="hs-identifier hs-var">vr</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#RegVirtual"><span class="hs-identifier hs-type">RegVirtual</span></a></span><span> </span><span id="local-6989586621681024865"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024865"><span class="hs-identifier hs-var">vr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RegSet -&gt; [Reg]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">RegSet
</span><a href="#local-6989586621681024867"><span class="hs-identifier hs-var">set</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-162"></span><span>  </span><span class="hs-comment">-- See Note [Unique Determinism and code generation]</span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span class="hs-comment">-- | Choose a node to spill from this graph</span><span>
</span><span id="line-166"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#chooseSpill"><span class="hs-identifier hs-type">chooseSpill</span></a></span><span>
</span><span id="line-167"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span>
</span><span id="line-168"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Base.html#Graph"><span class="hs-identifier hs-type">Graph</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.Class.html#RegClass"><span class="hs-identifier hs-type">RegClass</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#RealReg"><span class="hs-identifier hs-type">RealReg</span></a></span><span>
</span><span id="line-169"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span id="chooseSpill"><span class="annot"><span class="annottext">chooseSpill :: SpillCostInfo -&gt; Graph VirtualReg RegClass RealReg -&gt; VirtualReg
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#chooseSpill"><span class="hs-identifier hs-var hs-var">chooseSpill</span></a></span></span><span> </span><span id="local-6989586621681024863"><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024863"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681024862"><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024862"><span class="hs-identifier hs-var">graph</span></a></span></span><span>
</span><span id="line-172"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span>  </span><span id="local-6989586621681024861"><span class="annot"><span class="annottext">cost :: VirtualReg -&gt; Float
</span><a href="#local-6989586621681024861"><span class="hs-identifier hs-var hs-var">cost</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
-&gt; Graph VirtualReg RegClass RealReg -&gt; VirtualReg -&gt; Float
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#spillCost_length"><span class="hs-identifier hs-var">spillCost_length</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024863"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024862"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-173"></span><span>        </span><span id="local-6989586621681024859"><span class="annot"><span class="annottext">node :: Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024859"><span class="hs-identifier hs-var hs-var">node</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Node VirtualReg RegClass RealReg
 -&gt; Node VirtualReg RegClass RealReg -&gt; Ordering)
-&gt; [Node VirtualReg RegClass RealReg]
-&gt; Node VirtualReg RegClass RealReg
forall (t :: * -&gt; *) a.
Foldable t =&gt;
(a -&gt; a -&gt; Ordering) -&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#minimumBy"><span class="hs-identifier hs-var">minimumBy</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681024858"><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024858"><span class="hs-identifier hs-var">n1</span></a></span></span><span> </span><span id="local-6989586621681024857"><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024857"><span class="hs-identifier hs-var">n2</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Float -&gt; Float -&gt; Ordering
forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
</span><span class="hs-identifier hs-var">compare</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg -&gt; Float
</span><a href="#local-6989586621681024861"><span class="hs-identifier hs-var">cost</span></a></span><span> </span><span class="annot"><span class="annottext">(VirtualReg -&gt; Float) -&gt; VirtualReg -&gt; Float
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg -&gt; VirtualReg
forall k cls color. Node k cls color -&gt; k
</span><a href="GHC.Data.Graph.Base.html#nodeId"><span class="hs-identifier hs-var hs-var">nodeId</span></a></span><span> </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024858"><span class="hs-identifier hs-var">n1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg -&gt; Float
</span><a href="#local-6989586621681024861"><span class="hs-identifier hs-var">cost</span></a></span><span> </span><span class="annot"><span class="annottext">(VirtualReg -&gt; Float) -&gt; VirtualReg -&gt; Float
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg -&gt; VirtualReg
forall k cls color. Node k cls color -&gt; k
</span><a href="GHC.Data.Graph.Base.html#nodeId"><span class="hs-identifier hs-var hs-var">nodeId</span></a></span><span> </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024857"><span class="hs-identifier hs-var">n2</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>                </span><span class="annot"><span class="annottext">([Node VirtualReg RegClass RealReg]
 -&gt; Node VirtualReg RegClass RealReg)
-&gt; [Node VirtualReg RegClass RealReg]
-&gt; Node VirtualReg RegClass RealReg
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM VirtualReg (Node VirtualReg RegClass RealReg)
-&gt; [Node VirtualReg RegClass RealReg]
forall key elt. UniqFM key elt -&gt; [elt]
</span><a href="GHC.Types.Unique.FM.html#nonDetEltsUFM"><span class="hs-identifier hs-var">nonDetEltsUFM</span></a></span><span> </span><span class="annot"><span class="annottext">(UniqFM VirtualReg (Node VirtualReg RegClass RealReg)
 -&gt; [Node VirtualReg RegClass RealReg])
-&gt; UniqFM VirtualReg (Node VirtualReg RegClass RealReg)
-&gt; [Node VirtualReg RegClass RealReg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
-&gt; UniqFM VirtualReg (Node VirtualReg RegClass RealReg)
forall k cls color.
Graph k cls color -&gt; UniqFM k (Node k cls color)
</span><a href="GHC.Data.Graph.Base.html#graphMap"><span class="hs-identifier hs-var hs-var">graphMap</span></a></span><span> </span><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024862"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-175"></span><span>                </span><span class="hs-comment">-- See Note [Unique Determinism and code generation]</span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span>   </span><span class="hs-keyword">in</span><span>   </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg -&gt; VirtualReg
forall k cls color. Node k cls color -&gt; k
</span><a href="GHC.Data.Graph.Base.html#nodeId"><span class="hs-identifier hs-var hs-var">nodeId</span></a></span><span> </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024859"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-181"></span><span class="hs-comment">-- | Chaitins spill cost function is:</span><span>
</span><span id="line-182"></span><span class="hs-comment">--</span><span>
</span><span id="line-183"></span><span class="hs-comment">--   cost =     sum         loadCost * freq (u)  +    sum        storeCost * freq (d)</span><span>
</span><span id="line-184"></span><span class="hs-comment">--          u &lt;- uses (v)                         d &lt;- defs (v)</span><span>
</span><span id="line-185"></span><span class="hs-comment">--</span><span>
</span><span id="line-186"></span><span class="hs-comment">--   There are no loops in our code at the moment, so we can set the freq's to 1.</span><span>
</span><span id="line-187"></span><span class="hs-comment">--</span><span>
</span><span id="line-188"></span><span class="hs-comment">--  If we don't have live range splitting then Chaitins function performs badly</span><span>
</span><span id="line-189"></span><span class="hs-comment">--  if we have lots of nested live ranges and very few registers.</span><span>
</span><span id="line-190"></span><span class="hs-comment">--</span><span>
</span><span id="line-191"></span><span class="hs-comment">--               v1 v2 v3</span><span>
</span><span id="line-192"></span><span class="hs-comment">--      def v1   .</span><span>
</span><span id="line-193"></span><span class="hs-comment">--      use v1   .</span><span>
</span><span id="line-194"></span><span class="hs-comment">--      def v2   .  .</span><span>
</span><span id="line-195"></span><span class="hs-comment">--      def v3   .  .  .</span><span>
</span><span id="line-196"></span><span class="hs-comment">--      use v1   .  .  .</span><span>
</span><span id="line-197"></span><span class="hs-comment">--      use v3   .  .  .</span><span>
</span><span id="line-198"></span><span class="hs-comment">--      use v2   .  .</span><span>
</span><span id="line-199"></span><span class="hs-comment">--      use v1   .</span><span>
</span><span id="line-200"></span><span class="hs-comment">--</span><span>
</span><span id="line-201"></span><span class="hs-comment">--           defs uses degree   cost</span><span>
</span><span id="line-202"></span><span class="hs-comment">--      v1:  1     3     3      1.5</span><span>
</span><span id="line-203"></span><span class="hs-comment">--      v2:  1     2     3      1.0</span><span>
</span><span id="line-204"></span><span class="hs-comment">--      v3:  1     1     3      0.666</span><span>
</span><span id="line-205"></span><span class="hs-comment">--</span><span>
</span><span id="line-206"></span><span class="hs-comment">--   v3 has the lowest cost, but if we only have 2 hardregs and we insert</span><span>
</span><span id="line-207"></span><span class="hs-comment">--   spill code for v3 then this isn't going to improve the colorability of</span><span>
</span><span id="line-208"></span><span class="hs-comment">--   the graph.</span><span>
</span><span id="line-209"></span><span class="hs-comment">--</span><span>
</span><span id="line-210"></span><span class="hs-comment">--  When compiling SHA1, which as very long basic blocks and some vregs</span><span>
</span><span id="line-211"></span><span class="hs-comment">--  with very long live ranges the allocator seems to try and spill from</span><span>
</span><span id="line-212"></span><span class="hs-comment">--  the inside out and eventually run out of stack slots.</span><span>
</span><span id="line-213"></span><span class="hs-comment">--</span><span>
</span><span id="line-214"></span><span class="hs-comment">--  Without live range splitting, its's better to spill from the outside</span><span>
</span><span id="line-215"></span><span class="hs-comment">--  in so set the cost of very long live ranges to zero</span><span>
</span><span id="line-216"></span><span class="hs-comment">--</span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span class="hs-comment">-- spillCost_chaitin</span><span>
</span><span id="line-219"></span><span class="hs-comment">--         :: SpillCostInfo</span><span>
</span><span id="line-220"></span><span class="hs-comment">--         -&gt; Graph VirtualReg RegClass RealReg</span><span>
</span><span id="line-221"></span><span class="hs-comment">--         -&gt; VirtualReg</span><span>
</span><span id="line-222"></span><span class="hs-comment">--         -&gt; Float</span><span>
</span><span id="line-223"></span><span>
</span><span id="line-224"></span><span class="hs-comment">-- spillCost_chaitin info graph reg</span><span>
</span><span id="line-225"></span><span class="hs-comment">--         -- Spilling a live range that only lives for 1 instruction</span><span>
</span><span id="line-226"></span><span class="hs-comment">--         -- isn't going to help us at all - and we definitely want to avoid</span><span>
</span><span id="line-227"></span><span class="hs-comment">--         -- trying to re-spill previously inserted spill code.</span><span>
</span><span id="line-228"></span><span class="hs-comment">--         | lifetime &lt;= 1         = 1/0</span><span>
</span><span id="line-229"></span><span>
</span><span id="line-230"></span><span class="hs-comment">--         -- It's unlikely that we'll find a reg for a live range this long</span><span>
</span><span id="line-231"></span><span class="hs-comment">--         -- better to spill it straight up and not risk trying to keep it around</span><span>
</span><span id="line-232"></span><span class="hs-comment">--         -- and have to go through the build/color cycle again.</span><span>
</span><span id="line-233"></span><span>
</span><span id="line-234"></span><span class="hs-comment">--         -- To facility this we scale down the spill cost of long ranges.</span><span>
</span><span id="line-235"></span><span class="hs-comment">--         -- This makes sure long ranges are still spilled first.</span><span>
</span><span id="line-236"></span><span class="hs-comment">--         -- But this way spill cost remains relevant for long live</span><span>
</span><span id="line-237"></span><span class="hs-comment">--         -- ranges.</span><span>
</span><span id="line-238"></span><span class="hs-comment">--         | lifetime &gt;= 128</span><span>
</span><span id="line-239"></span><span class="hs-comment">--         = (spillCost / conflicts) / 10.0</span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span>
</span><span id="line-242"></span><span class="hs-comment">--         -- Otherwise revert to chaitin's regular cost function.</span><span>
</span><span id="line-243"></span><span class="hs-comment">--         | otherwise = (spillCost / conflicts)</span><span>
</span><span id="line-244"></span><span class="hs-comment">--         where</span><span>
</span><span id="line-245"></span><span class="hs-comment">--             !spillCost = fromIntegral (uses + defs) :: Float</span><span>
</span><span id="line-246"></span><span class="hs-comment">--             conflicts = fromIntegral (nodeDegree classOfVirtualReg graph reg)</span><span>
</span><span id="line-247"></span><span class="hs-comment">--             (_, defs, uses, lifetime)</span><span>
</span><span id="line-248"></span><span class="hs-comment">--                 = fromMaybe (reg, 0, 0, 0) $ lookupUFM info reg</span><span>
</span><span id="line-249"></span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span class="hs-comment">-- Just spill the longest live range.</span><span>
</span><span id="line-252"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#spillCost_length"><span class="hs-identifier hs-type">spillCost_length</span></a></span><span>
</span><span id="line-253"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span>
</span><span id="line-254"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Base.html#Graph"><span class="hs-identifier hs-type">Graph</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.Class.html#RegClass"><span class="hs-identifier hs-type">RegClass</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#RealReg"><span class="hs-identifier hs-type">RealReg</span></a></span><span>
</span><span id="line-255"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span>
</span><span id="line-256"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span>
</span><span id="line-257"></span><span>
</span><span id="line-258"></span><span id="spillCost_length"><span class="annot"><span class="annottext">spillCost_length :: SpillCostInfo
-&gt; Graph VirtualReg RegClass RealReg -&gt; VirtualReg -&gt; Float
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#spillCost_length"><span class="hs-identifier hs-var hs-var">spillCost_length</span></a></span></span><span> </span><span id="local-6989586621681024852"><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024852"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681024851"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024851"><span class="hs-identifier hs-var">reg</span></a></span></span><span>
</span><span id="line-259"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024850"><span class="hs-identifier hs-var">lifetime</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Float
</span><span class="hs-number">1</span></span><span class="annot"><span class="annottext">Float -&gt; Float -&gt; Float
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span class="annot"><span class="annottext">Float
</span><span class="hs-number">0</span></span><span>
</span><span id="line-260"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Float
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Float -&gt; Float -&gt; Float
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Float
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024850"><span class="hs-identifier hs-var">lifetime</span></a></span><span>
</span><span id="line-261"></span><span>        </span><span class="hs-keyword">where</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681024850"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024850"><span class="hs-identifier hs-var">lifetime</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-262"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SpillCostRecord -&gt; Maybe SpillCostRecord -&gt; SpillCostRecord
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024851"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-263"></span><span>                </span><span class="annot"><span class="annottext">(Maybe SpillCostRecord -&gt; SpillCostRecord)
-&gt; Maybe SpillCostRecord -&gt; SpillCostRecord
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo -&gt; VirtualReg -&gt; Maybe SpillCostRecord
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024852"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024851"><span class="hs-identifier hs-var">reg</span></a></span><span>
</span><span id="line-264"></span><span>
</span><span id="line-265"></span><span>
</span><span id="line-266"></span><span class="hs-comment">-- | Extract a map of register lifetimes from a `SpillCostInfo`.</span><span>
</span><span id="line-267"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#lifeMapFromSpillCostInfo"><span class="hs-identifier hs-type">lifeMapFromSpillCostInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostInfo"><span class="hs-identifier hs-type">SpillCostInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span>
</span><span id="line-268"></span><span id="lifeMapFromSpillCostInfo"><span class="annot"><span class="annottext">lifeMapFromSpillCostInfo :: SpillCostInfo -&gt; UniqFM VirtualReg (VirtualReg, Int)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#lifeMapFromSpillCostInfo"><span class="hs-identifier hs-var hs-var">lifeMapFromSpillCostInfo</span></a></span></span><span> </span><span id="local-6989586621681024845"><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024845"><span class="hs-identifier hs-var">info</span></a></span></span><span>
</span><span id="line-269"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(VirtualReg, (VirtualReg, Int))]
-&gt; UniqFM VirtualReg (VirtualReg, Int)
forall key elt. Uniquable key =&gt; [(key, elt)] -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#listToUFM"><span class="hs-identifier hs-var">listToUFM</span></a></span><span>
</span><span id="line-270"></span><span>        </span><span class="annot"><span class="annottext">([(VirtualReg, (VirtualReg, Int))]
 -&gt; UniqFM VirtualReg (VirtualReg, Int))
-&gt; [(VirtualReg, (VirtualReg, Int))]
-&gt; UniqFM VirtualReg (VirtualReg, Int)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(SpillCostRecord -&gt; (VirtualReg, (VirtualReg, Int)))
-&gt; [SpillCostRecord] -&gt; [(VirtualReg, (VirtualReg, Int))]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621681024843"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024843"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681024842"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024842"><span class="hs-identifier hs-var">life</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024843"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024843"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024842"><span class="hs-identifier hs-var">life</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-271"></span><span>        </span><span class="annot"><span class="annottext">([SpillCostRecord] -&gt; [(VirtualReg, (VirtualReg, Int))])
-&gt; [SpillCostRecord] -&gt; [(VirtualReg, (VirtualReg, Int))]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo -&gt; [SpillCostRecord]
forall key elt. UniqFM key elt -&gt; [elt]
</span><a href="GHC.Types.Unique.FM.html#nonDetEltsUFM"><span class="hs-identifier hs-var">nonDetEltsUFM</span></a></span><span> </span><span class="annot"><span class="annottext">SpillCostInfo
</span><a href="#local-6989586621681024845"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-272"></span><span>        </span><span class="hs-comment">-- See Note [Unique Determinism and code generation]</span><span>
</span><span id="line-273"></span><span>
</span><span id="line-274"></span><span>
</span><span id="line-275"></span><span class="hs-comment">-- | Determine the degree (number of neighbors) of this node which</span><span>
</span><span id="line-276"></span><span class="hs-comment">--   have the same class.</span><span>
</span><span id="line-277"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#nodeDegree"><span class="hs-identifier hs-type">nodeDegree</span></a></span><span>
</span><span id="line-278"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.Class.html#RegClass"><span class="hs-identifier hs-type">RegClass</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Base.html#Graph"><span class="hs-identifier hs-type">Graph</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.Class.html#RegClass"><span class="hs-identifier hs-type">RegClass</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#RealReg"><span class="hs-identifier hs-type">RealReg</span></a></span><span>
</span><span id="line-280"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span>
</span><span id="line-281"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-282"></span><span>
</span><span id="line-283"></span><span id="nodeDegree"><span class="annot"><span class="annottext">nodeDegree :: (VirtualReg -&gt; RegClass)
-&gt; Graph VirtualReg RegClass RealReg -&gt; VirtualReg -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#nodeDegree"><span class="hs-identifier hs-var hs-var">nodeDegree</span></a></span></span><span> </span><span id="local-6989586621681024840"><span class="annot"><span class="annottext">VirtualReg -&gt; RegClass
</span><a href="#local-6989586621681024840"><span class="hs-identifier hs-var">classOfVirtualReg</span></a></span></span><span> </span><span id="local-6989586621681024839"><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024839"><span class="hs-identifier hs-var">graph</span></a></span></span><span> </span><span id="local-6989586621681024838"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024838"><span class="hs-identifier hs-var">reg</span></a></span></span><span>
</span><span id="line-284"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681024837"><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024837"><span class="hs-identifier hs-var">node</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqFM VirtualReg (Node VirtualReg RegClass RealReg)
-&gt; VirtualReg -&gt; Maybe (Node VirtualReg RegClass RealReg)
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
-&gt; UniqFM VirtualReg (Node VirtualReg RegClass RealReg)
forall k cls color.
Graph k cls color -&gt; UniqFM k (Node k cls color)
</span><a href="GHC.Data.Graph.Base.html#graphMap"><span class="hs-identifier hs-var hs-var">graphMap</span></a></span><span> </span><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024839"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024838"><span class="hs-identifier hs-var">reg</span></a></span><span>
</span><span id="line-285"></span><span>
</span><span id="line-286"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681024836"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024836"><span class="hs-identifier hs-var">virtConflicts</span></a></span></span><span>
</span><span id="line-287"></span><span>           </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[VirtualReg] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span>
</span><span id="line-288"></span><span>           </span><span class="annot"><span class="annottext">([VirtualReg] -&gt; Int) -&gt; [VirtualReg] -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(VirtualReg -&gt; Bool) -&gt; [VirtualReg] -&gt; [VirtualReg]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681024834"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024834"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VirtualReg -&gt; RegClass
</span><a href="#local-6989586621681024840"><span class="hs-identifier hs-var">classOfVirtualReg</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024834"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">RegClass -&gt; RegClass -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">VirtualReg -&gt; RegClass
</span><a href="#local-6989586621681024840"><span class="hs-identifier hs-var">classOfVirtualReg</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024838"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-289"></span><span>           </span><span class="annot"><span class="annottext">([VirtualReg] -&gt; [VirtualReg]) -&gt; [VirtualReg] -&gt; [VirtualReg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet VirtualReg -&gt; [VirtualReg]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span>
</span><span id="line-290"></span><span>           </span><span class="hs-comment">-- See Note [Unique Determinism and code generation]</span><span>
</span><span id="line-291"></span><span>           </span><span class="annot"><span class="annottext">(UniqSet VirtualReg -&gt; [VirtualReg])
-&gt; UniqSet VirtualReg -&gt; [VirtualReg]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg -&gt; UniqSet VirtualReg
forall k cls color. Node k cls color -&gt; UniqSet k
</span><a href="GHC.Data.Graph.Base.html#nodeConflicts"><span class="hs-identifier hs-var hs-var">nodeConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024837"><span class="hs-identifier hs-var">node</span></a></span><span>
</span><span id="line-292"></span><span>
</span><span id="line-293"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024836"><span class="hs-identifier hs-var">virtConflicts</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet RealReg -&gt; Int
forall a. UniqSet a -&gt; Int
</span><a href="GHC.Types.Unique.Set.html#sizeUniqSet"><span class="hs-identifier hs-var">sizeUniqSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg -&gt; UniqSet RealReg
forall k cls color. Node k cls color -&gt; UniqSet color
</span><a href="GHC.Data.Graph.Base.html#nodeExclusions"><span class="hs-identifier hs-var hs-var">nodeExclusions</span></a></span><span> </span><span class="annot"><span class="annottext">Node VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024837"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-296"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-297"></span><span>
</span><span id="line-298"></span><span>
</span><span id="line-299"></span><span class="hs-comment">-- | Show a spill cost record, including the degree from the graph</span><span>
</span><span id="line-300"></span><span class="hs-comment">--   and final calculated spill cost.</span><span>
</span><span id="line-301"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#pprSpillCostRecord"><span class="hs-identifier hs-type">pprSpillCostRecord</span></a></span><span>
</span><span id="line-302"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.Class.html#RegClass"><span class="hs-identifier hs-type">RegClass</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-303"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-304"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.Graph.Base.html#Graph"><span class="hs-identifier hs-type">Graph</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#VirtualReg"><span class="hs-identifier hs-type">VirtualReg</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.Class.html#RegClass"><span class="hs-identifier hs-type">RegClass</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#RealReg"><span class="hs-identifier hs-type">RealReg</span></a></span><span>
</span><span id="line-305"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#SpillCostRecord"><span class="hs-identifier hs-type">SpillCostRecord</span></a></span><span>
</span><span id="line-306"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-307"></span><span>
</span><span id="line-308"></span><span id="pprSpillCostRecord"><span class="annot"><span class="annottext">pprSpillCostRecord :: (VirtualReg -&gt; RegClass)
-&gt; (Reg -&gt; SDoc)
-&gt; Graph VirtualReg RegClass RealReg
-&gt; SpillCostRecord
-&gt; SDoc
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#pprSpillCostRecord"><span class="hs-identifier hs-var hs-var">pprSpillCostRecord</span></a></span></span><span> </span><span id="local-6989586621681024830"><span class="annot"><span class="annottext">VirtualReg -&gt; RegClass
</span><a href="#local-6989586621681024830"><span class="hs-identifier hs-var">regClass</span></a></span></span><span> </span><span id="local-6989586621681024829"><span class="annot"><span class="annottext">Reg -&gt; SDoc
</span><a href="#local-6989586621681024829"><span class="hs-identifier hs-var">pprReg</span></a></span></span><span> </span><span id="local-6989586621681024828"><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024828"><span class="hs-identifier hs-var">graph</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681024827"><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024827"><span class="hs-identifier hs-var">reg</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681024826"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024826"><span class="hs-identifier hs-var">uses</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681024825"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024825"><span class="hs-identifier hs-var">defs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681024824"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024824"><span class="hs-identifier hs-var">life</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-309"></span><span>        </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span>
</span><span id="line-310"></span><span>        </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Reg -&gt; SDoc
</span><a href="#local-6989586621681024829"><span class="hs-identifier hs-var">pprReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VirtualReg -&gt; Reg
</span><a href="GHC.Platform.Reg.html#RegVirtual"><span class="hs-identifier hs-var">RegVirtual</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024827"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-311"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024826"><span class="hs-identifier hs-var">uses</span></a></span><span>
</span><span id="line-312"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024825"><span class="hs-identifier hs-var">defs</span></a></span><span>
</span><span id="line-313"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024824"><span class="hs-identifier hs-var">life</span></a></span><span>
</span><span id="line-314"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; SDoc) -&gt; Int -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(VirtualReg -&gt; RegClass)
-&gt; Graph VirtualReg RegClass RealReg -&gt; VirtualReg -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#nodeDegree"><span class="hs-identifier hs-var">nodeDegree</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg -&gt; RegClass
</span><a href="#local-6989586621681024830"><span class="hs-identifier hs-var">regClass</span></a></span><span> </span><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024828"><span class="hs-identifier hs-var">graph</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024827"><span class="hs-identifier hs-var">reg</span></a></span><span>
</span><span id="line-315"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Char] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">([Char] -&gt; SDoc) -&gt; [Char] -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Float -&gt; [Char]
forall a. Show a =&gt; a -&gt; [Char]
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">(Float -&gt; [Char]) -&gt; Float -&gt; [Char]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Float
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024826"><span class="hs-identifier hs-var">uses</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024825"><span class="hs-identifier hs-var">defs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-316"></span><span>                       </span><span class="annot"><span class="annottext">Float -&gt; Float -&gt; Float
forall a. Fractional a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#%2F"><span class="hs-operator hs-var">/</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Float
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(VirtualReg -&gt; RegClass)
-&gt; Graph VirtualReg RegClass RealReg -&gt; VirtualReg -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillCost.html#nodeDegree"><span class="hs-identifier hs-var">nodeDegree</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg -&gt; RegClass
</span><a href="#local-6989586621681024830"><span class="hs-identifier hs-var">regClass</span></a></span><span> </span><span class="annot"><span class="annottext">Graph VirtualReg RegClass RealReg
</span><a href="#local-6989586621681024828"><span class="hs-identifier hs-var">graph</span></a></span><span> </span><span class="annot"><span class="annottext">VirtualReg
</span><a href="#local-6989586621681024827"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-317"></span><span>
</span><span id="line-318"></span></pre></body></html>